#!/usr/bin/env python
# -*- coding: utf-8 -*-

from django.db import models
from django.core.validators import MaxValueValidator
import os
import sys
import django

sys.path.append(r"web")
sys.path.append(r"algorithm")
sys.path.append(r"cta")

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'adam3.settings')
django.setup()


class Quant2CommodityFutureFilter(models.Model):
    """
    量化2--商品期货过滤表
    """

    # 主键
    id = models.AutoField(primary_key=True)

    # 期货代码
    code = models.CharField(max_length=32, db_index=True, null=True, blank=True)

    # 成交量
    turnover = models.BigIntegerField(validators=[MaxValueValidator(9223372036854775807)], null=True, blank=True)

    # 过去n天的涨跌百分比
    up_down_percentage_with_n_date = models.DecimalField(max_digits=32, decimal_places=3, null=True, blank=True)

    # 归一化的120日方差
    normalization_variance120 = models.DecimalField(max_digits=32, decimal_places=3, null=True, blank=True)

    class Meta:
        managed = True
        db_table = 'quant2_c_f_filter'
        verbose_name = '量化2--商品期货过滤表'
        verbose_name_plural = verbose_name
        # 单列索引
        # indexes = [
        #     models.Index(fields=['code']),
        #     models.Index(fields=['k_line_period_type']),
        #     models.Index(fields=['begin_time']),
        #     models.Index(fields=['end_time']),
        #     models.Index(fields=['name']),
        # ]
        # 联合索引
        # index_together = [('code', 'transaction_date')]